package com.example.demo.mapper;

import com.example.demo.entity.School;
import com.example.demo.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.List;

public interface UserMapper extends JpaRepository<User, String> {
    @Query(name="findUserByID",nativeQuery = true,value="select * from user where id=:ID")
    User findUserByID(String ID);

    @Query(name="findUserByToken",nativeQuery = true,value="select * from user where token = :token")
    User findUserByToken(String token);

    @Query(name="findUserByMail",nativeQuery = true, value="select * from user where mail = :mail")
    User findUserByMail(String mail);

    @Query(name="findUserByPhonenumber",nativeQuery = true, value="select * from user where phonenumber=:phonenumber")
    User findUserByPhonenumber(String phonenumber);

    @Query(name="findUserBySchool",nativeQuery = true, value="select * from user where uschool=:school")
    List<User> findUserBySchool(String school);

    @Query(name="findUserByMajor",nativeQuery = true, value="select * from user where umajor=:major")
    List<User> findUserByMajor(String major);

}


